<?php
if (!empty($_POST['id'])) {
    if (!empty($_POST['pw'])) {
        require_once 'connect.php';
        $id = $_POST['id'];
        $pw = $_POST['pw'];
        $sql = "SELECT * FROM user WHERE id='$id' AND pw='$pw'";
        $result = mysqli_query($sqlconnect, $sql);
        $num = mysqli_num_rows($result);
        if ($num == 0) {
            echo '登录失败';
            echo "<a href='login.php'>点击返回</a>";
        } else {
            echo '登录成功';
            echo "<a href='login.php'>点击返回</a>";
        }
        mysqli_close($sqlconnect);//关闭连接
    }
} else {
    echo '<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录</title>
</head>
<body>
<h1>登录</h1>
<form action="login.php" method="post">
    id<br>
    <input type="text" name="id" value="">
    <br>
pw<br>
    <input type="text" name="pw" value="">
    <br><br>
    <input type="submit" value="登录">
</form>
</body>
</html>';
}
